package com.cuijq.ms.visitordesign.v5;

import com.cuijq.ms.visitordesign.v5.impl.PPTFile;
import com.cuijq.ms.visitordesign.v5.impl.PdfFile;
import com.cuijq.ms.visitordesign.v5.impl.WordFile;
import java.util.ArrayList;
import java.util.List;

/**
 * @author by CuiJQ
 * @Classname ToolApplication
 * @Description ToolApplication Description
 * @Date 2021/5/29 17:39
 */
public class ToolApplication {

  public static void main(String[] args) {
    List<ResourceFile> resourceFiles = listAllResourceFiles(args[0]);
    for (ResourceFile resourceFile : resourceFiles) {
      Extractor extractor = ExtractorFactory.getExtractor(resourceFile.getType());
      extractor.extract2txt(resourceFile);
    }
  }

  private static List listAllResourceFiles(String resourceDirectory) {
    List<ResourceFile> resourceFiles = new ArrayList<>();
    //...根据后缀(pdf/ppt/word)由工厂方法创建不同的类对象(PdfFile/PPTFile/WordFile)
    resourceFiles.add(new PdfFile("a.pdf"));
    resourceFiles.add(new WordFile("b.word"));
    resourceFiles.add(new PPTFile("c.ppt"));
    return resourceFiles;
  }
}
